package com.itheima.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

public class AOPAdvice {
        public void before(JoinPoint jp){
//                通过JoinPoint参数获取调用原始方法所携带的参数
                System.out.println("before...");
                Object[] args = jp.getArgs();
                for (Object arg : args) {
                        System.out.println(args);
                }
        }

        public void before1(int x,int y){
                System.out.println("before(int)..."+x+","+y);
        }

        public void after(JoinPoint jp){
                Object[] args = jp.getArgs();

        }

        public void afterReturing(Object ret){
                System.out.println("afterReturning..."+ret);
        }

        public void afterThrowing(Throwable t){
                System.out.println("afterThrowing..."+t.getMessage());
        }

        public Object around(ProceedingJoinPoint pjp){
                System.out.println("around before...");
                Object ret =null;

                try {
                        ret=pjp.proceed();
                } catch (Throwable throwable) {
                        System.out.println("around...exception..."+throwable.getMessage());
                }
                System.out.println("around...exception"+ret);
                return ret;
        }
        public void before2(){
                System.out.println("before..2");
        }
        public void before3(){
                System.out.println("before..3");
        }


}
